home *** CD-ROM | disk | FTP | other *** search
- Path: news.airtime.co.uk!usenet
- From: wysiwyg@glympton.airtime.co.uk (Adam L Rice)
- Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather
- Subject: Re: What Should An Exception Handling Do? -- Clarification of rules
- Date: 2 Apr 1996 08:11:44 +0100
- Organization: The Rice family.
- Message-ID: <4jqjvg$d9@glympton.airtime.co.uk>
- References: <4irn11$7ln@mimas.brunel.ac.uk> <4j03p4$fbt@hoho.quake.net> <Doq3sv.MzA@research.att.com> <vwjg2ao6hqp.fsf@osfb.aber.ac.uk>
- NNTP-Posting-Host: glympton.airtime.co.uk
-
- >The exception facility of e.g. C++ is merely a (rather ad-hoc and
- >opaque) way of allowing the definition of what are in effect dynamically
- >scoped procedure names, forcibly coupled with non-local control
- >transfer.
-
- So, let me see if I've understood. What you're basically saying is that
- instead of doing (in Java):
-
- try {
- sock = new Socket("wallawalla.mit.edu", 3456);
- } catch (IOException e) {
- ... // handle the exception
- }
- ... // use the socket
-
- we should do something like:
-
- if (Socket.ConnectWillWork("wallawalla.mit.edu", 3456) {
- sock = new Socket("wallawalla.mit.edu", 3456);
- ... // use the socket
- } else {
- ... // handle the exception
- }
-
- Hmmmm... that's a lovely code style! I think we can call this techique
- 'APIx2', for obvious reasons.
-
- But I'm not entirely clear, it might be you were saying we should do:
-
- sock = new Socket("wallawalla.mit.edu", 3456, new CantConnectHandler());
- if (!CantConnectHandler.ConnectFailed) {
- ... // use the socket
- }
-
- // some time later
- Class CantConnectHandler implements IOExceptionHandler {
- public int ConnectFailed=false;
- public handle(Object context) {
- ... // handle the exception
- }
- }
-
- Hmmm... that too is delightful! I can't think of a good name for it, so I
- think 'VerboseAndSlow' will have to do, though it doesn't capture the true
- joy of using this programming style. I can't help but feel that it's a real
- pity that the Java developers weren't open-minded enough to provide
- alternate APIs for people who wanted to program using these coding styles.
-
-
- Well, I say one thing for you computer scientist types, you certainly know
- how to make a guy glad of what he's got! I'll never complain about having to
- write a try ... catch statement again!
-
- Have a nice day!
-
- ,==========================================================================.
- | \ /\/( |\ /\//' | Adam L Rice -|- wysiwyg@glympton.airtime.co.uk |
- | \/\/ / )| \/\/ / \_| | Resume: http://www.csv.warwick.ac.uk/~mauhb/cv |
- `=========================================================================='
-